/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exatrez.stripes.util;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import exatrez.dao.SeverityCodeDAO;
import exatrez.dao.StatusRemarkCodeDAO;
import exatrez.dao.VesselDAO;
import exatrez.model.Department;
import exatrez.model.SeverityCode;
import exatrez.model.StatusRemarkCode;
import exatrez.model.UserGroup;
import exatrez.model.Groups;
import exatrez.model.PriorityCode;
import exatrez.model.User;
import exatrez.model.Vessel;
import exatrez.stripes.BaseActionBean;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author fikri
 */
@Singleton
public class ListUtil extends BaseActionBean {

    @Inject
    VesselDAO vesselDAO;
    @Inject
    SeverityCodeDAO severityCodeDAO;
    @Inject
    StatusRemarkCodeDAO statusRemarkCodeDAO;
    @Inject
    protected com.google.inject.Provider<Session> sessionProvider;

    public List<Vessel> getVesselList() {
//        return vesselDAO.findAll();
        String query = "SELECT a FROM Vessel a WHERE a.active = 'Y' ";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }

    public List<SeverityCode> getSeverityList() {
        return severityCodeDAO.findAll();
    }

    public List<StatusRemarkCode> getStatusRemarkList() {
        return statusRemarkCodeDAO.findAll();
    }

    public List<UserGroup> getListSuper() {
        String query = "SELECT a FROM UserGroup a WHERE group.groupId = 2 and a.active = 'Y'";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }
    
     public List<UserGroup> getListCrew() {
        String query = "SELECT a FROM UserGroup a WHERE group.groupId = 14 and a.active = 'Y'";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }
     
      public List<UserGroup> getListProc() {
        String query = "SELECT a FROM UserGroup a WHERE group.groupId = 15 and a.active = 'Y'";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }

    public List<Groups> getListRoles() {
        String query = "SELECT a FROM Groups a WHERE a.active = 'Y' ";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }

    public List<Department> getListDepart() {
        String query = "SELECT a FROM Department a WHERE a.active = 'Y' ";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }

    public List<User> getListUsers() {
        String query = "SELECT a FROM User a WHERE a.activate = 'Y' ";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }

    public List<UserGroup> getListUsersNotSuper() {
        String query = "SELECT a FROM UserGroup a WHERE a.active = 'Y' and group.groupId != 2";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }

    public List<PriorityCode> getListPriorityCode() {
        String query = "SELECT a FROM PriorityCode a WHERE a.priorityCodeId is not null ";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }
}
